<?php

namespace backend\helpers;

use yii\helpers\ArrayHelper;
use yii\helpers\Html;

class SimpleFlagHelper
{
    const IS_TRUE = 1;
    const IS_FALSE = 0; 

    public static function statusList()
    {
        return [
            self::IS_TRUE => 'Да',
            self::IS_FALSE => 'Нет',
        ];
    }

    public static function statusName($status)
    {
        if($status === NULL)
        {
            return 'Не задано';
        }
        else
        {
            return ArrayHelper::getValue(self::statusList(), $status);
        }
    }

    public static function statusLabel($status)
    {
        if($status === NULL)
        {
            $class = 'label label-default';
        }
        else
        {
            switch ($status) {
                case self::IS_FALSE:
                    $class = 'label label-danger';
                    break;
                case self::IS_TRUE:
                    $class = 'label label-success';
                    break;
                default:
                    $class = 'label label-default';
            }
        }

        return Html::tag('span', self::statusName($status), [
            'class' => $class,
        ]);
    }
}